﻿<!DOCTYPE html>
<html>
<head>
    <title>计划审核</title>
    <link href="/static/css/framework-font.css" rel="stylesheet"/>
    <script src="/static/js/jquery-2.1.1.js"></script>
    <script src="/static/bootstrap/js/bootstrap.js"></script>
    <link href="/static/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
    <script src="/static/js/jquery.cookie.js"></script>
    <link href="/static/css/framework-theme.css" rel="stylesheet"/>
    <script src="/static/js/framework-ui.js"></script>
    <script src="/static/js/framework-clientdata.js"></script>
    <script src="/static/js/yii.js"></script>

    <!--引用layui弹框插件-->
    <link href="/static/layui/css/layui.css" rel="stylesheet"/>
    <script src="/static/layui/layui.js"></script>


    <link href="/static/css/default/public.css" rel="stylesheet"/>
</head>
<body>
<style>
    .layui-inline{margin-bottom:15px;display: inline-block}
    .layui-input-block{margin-left:0px!important;}
    .layui-table th{text-align: center}
    .title{width:150px;text-align: center;background-color: #FFFFFF!important;}
    .layui-layer-demo{top:20px!important;}
    .layui-layer-dialog{top:180px!important;}
    .one{color: red}
    .show_view{position: relative}
    .show_view span{position: absolute;top:0px;font-size:10px;left:0px;background-color: red;color: #FFFFFF;padding:0px 6px}
    .layui-table td, .layui-table th{
        text-align: center!important;
    }
    .zxd_image{
        width:20px;
    }
</style>
<div class="newtest">


    <form class="layui-form layui-form-pane form-horizontal" name="layui-form" action="" >

        <div class="layui-form-item layui-col-md12">
            <label class="layui-form-label">计划类别</label>
            <div class="input-group col-xs-10" style="float: left">
                <select lay-verify="plan_category" lay-filter="plan_category" class="select" >
                    <option value="0">请选择</option>
                    {volist name="plan_category" id="vo" }
                    <option value="{$key}" {if condition="$detail['plan_category'] eq $key"} selected {/if}>{$vo}</option>
                    {/volist}
                </select>
            </div>
        </div>

        <div class="layui-form-item layui-col-md12" style="background-color:#FFFFFF!important;">
        <table class="layui-table">
            <thead>
            <tr>
                <th class="title">进展</th>
                <th class="title">进展细节</th>
                <th class="title">计划完成时间</th>
                <th class="title">状态</th>
                <th class="title">审核状态</th>
                <th class="title">服务单位</th>
                <th class="title" style="width:340px">操作</th>
            </tr>
            </thead>
            <tbody>
                {volist name="list" id="vo"}

                    {volist name="$vo.child" id="v"}
                    <tr>
                        <td>{$vo.name}</td>
                        <td>{$v.name}</td>
                        <td>
                            {if condition="$v['color'] == 1"}
                                已完成
                            {else/}
                                {$v.time}
                            {/if}
                        </td>
                        <td>
                            {if condition="$v['is_shen'] == '1'"}
                            <font style="color: #FF0000;position: absolute;top: 0px;left:10px;">审</font>
                            {/if}
                            {if condition="$v['color'] == '0'"}
                                -
                                <!--<img class="zxd_image" src="/static/images/baise.png">-->
                            {elseif condition="$v['color'] == 1"}
                                <img class="zxd_image" src="/static/images/green.png">
                            {elseif condition="$v['color'] == 2"}
                                <img class="zxd_image" src="/static/images/orange.png">
                            {elseif condition="$v['color'] == 3"}
                                <img class="zxd_image" src="/static/images/red.png">
                            {else/}
                                -
                            {/if}
                        </td>
                        <td>{$v.status}</td>
                        <td>{$v.duty_unit}</td>
                        <td>
                            <!--{if condition="$v.applyCount>0"}-->
                                <!--<div class="layui-btn layui-btn-xs layui-btn-warm apply" data-typeId="{$v.id}" data-proId = "{$pro_id}">延期申请</div>-->
                            <!--{else/}-->
                                <!--<div class="layui-btn layui-btn-xs apply" data-typeId="{$v.id}" data-proId = "{$pro_id}">延期申请</div>-->
                            <!--{/if}-->
                            <div class="layui-btn layui-btn-xs detail" data-val="{$v.plan_id}" data-type="{$v.id}" data-proId = "{$pro_id}">查看详情</div>
                            <div class="layui-btn layui-btn-xs layui-btn-warm status" data-val="{$v.plan_id}">更新状态</div>
                            <div class="layui-btn layui-btn-xs layui-btn-danger del" data-val="{$v.plan_id}">删除</div>
                        </td>
                    </tr>
                    {/volist}

                {/volist}
            </tbody>


        </table>
    </div>

    </form>
</div>
<script src="/static/js/index.js"></script>
<script src="/static/js/indextab.js"></script>
<script src="/static/js/pace.min.js"></script>
<!--弹框js-->
<script src="/static/js/yii.js"></script>
<script>
    var id = "{$pro_id}";  //项目id
    layui.use(['form','jquery','layer','laydate','table','upload'], function() { //独立版的layer无需执行这一句
        var $ = layui.jquery, layer = layui.layer,upload = layui.upload;;
        var form = layui.form;
        var laydate = layui.laydate;
        var table = layui.table //表格

        //更新项目计划类别
        form.on('select(plan_category)', function (data) {
            //触发联动
            var plan_id = data.value;
            $.ajax({
                type: 'post',
                url: "{:URL('project/communal/updatePlan')}",
                data: {id: id,plan_id:plan_id},
                dataType: 'JSON',
                success: function (res) {
                    location.reload();
                },
                error: function (res) {
                }
            });
        });

        //日期范围
        laydate.render({
            elem: '#test6'
            , range: true
        });

        var url = "{:URL('project/AdvancePlan/index')}";
        var detail = "{:URL('project/AdvancePlan/detail')}";

        //搜索操作
        $('.serach_btn').click(function () {
            var data=$("form[name='searchForm']").serializeArray();
            var dataVal = {};
            $.each(data, function(i, item){
                dataVal[item.name] = item.value;
            });
            var where = dataVal;
            search(table,url,where)
        });


        //列表
        var data=$("form[name='searchForm']").serializeArray();
        var dataVal = {type:'list'};
        $.each(data, function(i, item){
            dataVal[item.name] = item.value;
        });
        var where = dataVal;
        var title = "审核列表";
        var cols = [[
            {type: 'checkbox', fixed: 'left'}
            // ,{field: 'id', title: 'ID',  sort: true, fixed: 'left',width:80, align:'center'}
            // ,{field: 'typeName', title: '计划类别', align:'center'}
            ,{field: 'content', title: '汇报内容', align:'center'}
                ,{field: 'time', title: '时间', align:'center'}
                    ,{field: 'end_time', title: '汇报时间', align:'center'}
            ,{field: 'addtime', title: '创建时间', align:'center'}
            ,{field: 'status', title: '审核状态', align:'center',toolbar: '#statusTpl'}
            ,{fixed: 'right',title: '操作',align:'center', toolbar: '#barDemo',width:280}
        ]];
        showlist(table,url,where,title,cols,0,10,'#demo','#toolbarDemo');
        $(".layui-laypage-skip").find("input").val(3 );
        $(".layui-laypage-btn").click();


        //更新状态视图
        $(".status").click(function () {
            var id =  $(this).attr("data-val");
            var showUrl = "{:URL('project/AdvancePlan/statusView')}?id="+id;
            showView1(showUrl,"更新状态");
        });

        //查看详情
        $(".detail").click(function () {
            var id =  $(this).attr("data-val");
            var type_id =  $(this).attr("data-type");
            var proId =  $(this).attr("data-proId");
            var showUrl = detail+"?id="+id+"&type_id="+type_id+"&proId="+proId;
            showView(showUrl,"详情");
        });

        //删除操作
        $(".del").click(function () {
            var id =  $(this).attr("data-val");
            layer.confirm('是否确定操作?', function (index) {
                $.ajax({
                    type: "post",
                    url: "{:URL('project/AdvancePlan/del')}",
                    data:{id: id},
                    dataType: "json",
                    success: function (data) {
                        if(data.code!=0){
                            layer.alert(data.msg);
                        }else{
                            window.location.reload()
                        }
                    }
                });
            });
        });

        //延期申请
        $(".apply").click(function () {
            var typeId =  $(this).attr("data-typeId");
            var proId =  $(this).attr("data-proId");
            var showUrl = "{:URL('project/AdvanceApply/index')}?typeId="+typeId+"&proId="+proId;
            showView(showUrl,"延期申请",['关闭'],2);

        });



        //监听行工具事件
        table.on('tool(demo)', function(obj) {
            var id = obj.data.id;
            switch (obj.event) {
                case 'del':
                    layer.confirm('是否确定操作?', function (index) {
                        let url = "{:URL('project/AdvancePlan/del')}";
                        let where = {id: id};
                        publicDel(table, url, where, obj, index, 1);
                    });
                    break;
                case 'detail':
                    var showUrl = detail+"?id="+id;
                    showView(showUrl,"详情");
                    break;
            }
        })

        function showView1(showUrl,type){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['800px','200px'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: type,
                content:showUrl,
                btn:['确定','关闭'],
                yes: function (index,layero) {

                    var body = layer.getChildFrame('body', index);
                    var data = body.find("form[name='saveForm']").serializeArray();
                    $.ajax({
                        type: "post",
                        url: "{:URL('project/AdvancePlan/dostatus')}",
                        data:data,
                        dataType: "json",
                        success: function (data) {
                            if(data.code!=0){
                                layer.alert(data.msg);
                            }else{
                                window.location.reload()
                                layer.close(index);
                            }
                            // table.reload('demo')
                        }
                    });

                },
            });
        }


        function showView(showUrl,title,btn=['确定','关闭'],type=1){
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                area: ['900px','550px'],            //宽度450px,高自适应
                anim: 2,
                shadeClose: false, //开启遮罩关闭,
                maxmin: true,
                title: title,
                content:showUrl,
                btn:btn,
                yes: function (index,layero) {

                    if(type==1){
                        var body = layer.getChildFrame('body', index);
                        body.find("button[id='getData']").click()
                        setTimeout(()=>{
                            var data = body.find("form[name='saveForm']").serializeArray();
                            // data.push({name: "plan_id", value: plan_id});
                            $.ajax({
                                type: "post",
                                url: "{:URL('project/AdvancePlan/save')}",
                                data:data,
                                dataType: "json",
                                success: function (data) {
                                    if(data.code!=0){
                                        layer.alert(data.msg);
                                    }else{
                                        window.location.reload()
                                        layer.close(index);
                                    }
                                    // table.reload('demo')
                                }
                            });
                        }, 300)
                    }else{
                        layer.close(index);
                    }


                },
            });
        }


        //头工具栏事件
        table.on('toolbar(demo)', function(obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            switch (obj.event) {
                case 'getCheckLength':
                    var data = checkStatus.data;
                    var id=[];
                    for (var i = 0; i < data.length; i++) {
                        id[i] = data[i].id;
                    }
                    if(id.length==0){
                        layer.alert("请选择需操作的数据");return;
                    }

                    layer.confirm('是否确定操作?', function(index){
                        let url="{:URL('project/AdvancePlan/del')}";
                        let where = {id:id};
                        publicDel(table,url,where,obj,index,1);
                    });
                    break;
            }
        });


        layui.form.render('select');
    });
</script>
</body>
</html>
